package com.myjunjie.blog.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.JsonObject;

import com.myjunjie.blog.service.IArticleService;
import com.myjunjie.blog.service.impl.ArticleServiceImpl;


public class GetListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void init() throws ServletException {

	}

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html");

		//获取参数
		String startNum = request.getParameter("startNum");
		String counted = request.getParameter("counted"); // 获取到文章标题
		
		// 调用服务
		IArticleService articleService = new ArticleServiceImpl();
		JsonObject object = articleService.getList(startNum, counted);

		//返回结果
		PrintWriter out = response.getWriter();
		out.println(object);
	}

	public void destroy() {

	}

}
